package cn.edu.zafu.bigdata.sxa;

import java.util.HashMap;

// 学生成绩管理类
public class StudentGradeManager {
    // 使用HashMap存储学生姓名和对应的成绩
    private HashMap<String, Integer> studentGrades;

    public StudentGradeManager() {
        studentGrades = new HashMap<>();
    }

    // 添加学生成绩
    public void addStudent(String name, int grade) {
        studentGrades.put(name, grade);
    }

    // 根据学生姓名获取成绩
    public int getGrade(String name) {
        return studentGrades.getOrDefault(name, -1);
    }

    // 删除学生成绩
    public void removeStudent(String name) {
        studentGrades.remove(name);
    }
}


class TestStudentGradeManager {
    public static void main(String[] args) {

        StudentGradeManager manager = new StudentGradeManager();

        // 添加学生成绩
        manager.addStudent("hj", 100);
        manager.addStudent("sj", 90);
        manager.addStudent("sz", 80);

        // 查询学生成绩
        System.out.println("hj的成绩为" + manager.getGrade("hj"));
        System.out.println("sj的成绩为" + manager.getGrade("sj"));
        System.out.println("sz的成绩为" + manager.getGrade("sz"));
        System.out.println("sxa的成绩为" + manager.getGrade("sxa"));

        // 删除学生成绩
        manager.removeStudent("sz");
        System.out.println("sz的成绩为" + manager.getGrade("sz"));
    }
}